import cv2
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.outputs import OutputKeys

universal_matting = pipeline(Tasks.universal_matting,model='damo/cv_unet_universal-matting')
path = r'D:\mywork\imgs\vercode\tmp\23.jpg'
result = universal_matting(path)
cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])